package com.zy.web.demo.duoxiancheng.demo19;

/**
 * @author <a href="mailto:zhouyong@cqyyt.com">zy</a>
 * @version 1.0
 * @date 2020/8/19 15:33
 */
public class Producer {

    private String lock;

    public Producer(String lock){
        this.lock = lock;
    }

    public void setValue(){
        try {
            synchronized (lock){
                if ( !ValueObject.value.equals("")){
                    lock.wait();
                }
                String value = System.currentTimeMillis()+"_"+System.nanoTime();
                System.out.println("set的值是"+value);
                ValueObject.value = value;
                lock.notify();
            }

        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }

}
